package ai.people.netmon.telegram.controller;

import ai.people.netmon.framework.businessenum.AnalysisSourceEnum;
import ai.people.netmon.framework.domain.telegram.vo.account.BusinessLeadsAccount;
import ai.people.netmon.framework.model.request.PageKeyWordsRequest;
import ai.people.netmon.framework.model.response.PageResponse;
import ai.people.netmon.framework.model.response.Result;
import ai.people.netmon.framework.utils.ResultUtil;
import ai.people.netmon.telegram.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 帐号相关
 *
 * @author yuanqinglong
 * @date 2022/1/21 10:54
 */
@RestController
@RequestMapping("/account")
public class AccountController {


    @Autowired
    private AccountService accountServiceImpl;


    /**
     * 通过用户名查询账号信息
     *
     * @param userId 用户id
     * @return {@link Result}<{@link BusinessLeadsAccount}>
     */
    @GetMapping("/business/{userId}")
    public Result<BusinessLeadsAccount> getAccountByUsername(@PathVariable("userId") Long userId) {
        BusinessLeadsAccount accountList = accountServiceImpl.getAccountByUserId(userId);
        accountList.setInfoType(AnalysisSourceEnum.telegram.name());
        return ResultUtil.success(accountList);
    }


    /**
     * 业务线索帐户列表
     *
     * @param pageKeyWordsRequest 页面关键字请求
     * @return {@link Result}<{@link PageResponse}<{@link BusinessLeadsAccount}>>
     */
    @PostMapping("/business/accountList")
    public Result<PageResponse<BusinessLeadsAccount>> businessAccountList(@RequestBody PageKeyWordsRequest pageKeyWordsRequest) {
        // 通过登录用户的业务类型 查询tg_user_tag中是此类型的用户信息
        PageResponse<BusinessLeadsAccount> accountList = accountServiceImpl.businessAccountList(pageKeyWordsRequest);
        return ResultUtil.success(accountList);
    }

    //
    ///**
    // * 搜索账户列表
    // *
    // * @param searchAccountRequest 搜索帐户请求
    // * @return {@link Result}<{@link PageResponse}<{@link BusinessLeadsAccount}>>
    // */
    //@PostMapping("/search/accountList")
    //public Result<PageResponse<BusinessLeadsAccount>> searchAccountList(@RequestBody SearchAccountChannelRequest searchAccountRequest) {
    //    PageResponse<BusinessLeadsAccount> searchAccount = accountServiceImpl.searchAccount(searchAccountRequest);
    //    return ResultUtil.success(searchAccount);
    //}

}
